<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let hws = function(a) {
            //首先判断回文数a不小于零并且个位数和回文数不等于零
            if (a < 0 || (a % 10 === 0 && a != 0)) return false;
            let x = 0
                //当回文数大于x时一直循环
            while (a > x) {
                //x等于每次回文数除十取整得出的数乘十加上回文数取余
                x = x * 10 + (a % 10)
                a = parseInt(a / 10)
            }
            return a === x || a === parseInt(x / 10)
        }
        console.log(hws(123))
  </script>
</body>
</html>